<?
	require_once "../../_func/__Global.php";
	require_once "../../_func/__Local.php";
	require_once "../../_func/__MysqlFunc.php";
	require_once "../../_func/_CodeFunc.php";
	$_GET['menu1'] = ($_GET['menu1'])?$_GET['menu1']:'01';
	$_GET['menu2']=02;
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>수발주입력 :: 농협전북지부 ERP시스템 ::</title>
<link href="../css/layout.css" type="text/css" rel="stylesheet" />
<link type="text/css" href="/css/hot-sneaks/jquery-ui-1.8.18.custom.css" rel="stylesheet" />
<script type="text/javascript" src="/js/jquery-1.7.1.min.js"></script>
<script type="text/javascript" src="/js/jquery-ui-1.8.18.custom.min.js"></script>
<script type="text/javascript" src="/js/common.js"></script>
<script type="text/javascript" src="/js/print_excel.js"></script>
<script type="text/javascript">
$(function(){
	// Datepicker
	$('#order_date').datepicker({
		inline: true,
		showOn: 'button',
		buttonImage:"/img/ico_cal.jpg",
		buttonImageOnly: true
	});
	//hover states on the static widgets
	$('#dialog_link, ul#icons li').hover(
		function() { $(this).addClass('ui-state-hover'); },
		function() { $(this).removeClass('ui-state-hover'); }
	);
	$('#order_arrivaldate').datepicker({
		inline: true,
		showOn: 'button',
		buttonImage:"/img/ico_cal.jpg",
		buttonImageOnly: true
	});

});
</script>
<script type="text/javascript">
	function value_check()
	{
		if (!isEmpty($('#order_date')))
		{
			alert("등록일을 입력하세요");
			$('#order_date').focus();
			return;
		}
		if (!isEmpty($('#jbnh_seq')))
		{
			alert("농협을 선택하세요");
			$('#jbnh_seq').focus();
			return;
		}
		if (!isEmpty($('#order_type')))
		{
			alert("거래방법을 선택하세요");
			$('#order_type').focus();
			return;
		}
		if (!isEmpty($('#order_item1')))
		{
			alert("품목을 선택하세요");
			$('#order_item1').focus();
			return;
		}
		if (!isEmpty($('#order_item2')))
		{
			alert("품종을 선택하세요");
			$('#order_item2').focus();
			return;
		}
		if (!isEmpty($('#order_grade2')))
		{
			alert("등급을 선택하세요");
			$('#order_grade2').focus();
			return;
		}
		if (!isEmpty($('#order_standard2')))
		{
			alert("규격을 선택하세요");
			$('#order_standard2').focus();
			return;
		}
		if (!isEmpty($('#order_weight2')))
		{
			alert("중량 선택하세요");
			$('#order_weight2').focus();
			return;
		}
		if (!isEmpty($('#order_number')))
		{
			alert("수량을 입력하세요");
			$('#order_number').focus();
			return;
		}
		if (!isNumber($('#order_number')))
		{
			alert("수량은 숫자만 입력하세요");
			$('#order_number').val("");
			$('#order_number').focus();
			return;
		}
		if ($('#order_number').val()<=0)
		{
			alert("수량은 0보다 큰수를 입력하세요");
			$('#order_number').val("");
			$('#order_number').focus();
			return;
		}
		if (!isEmpty($('#order_destination1')))
		{
			alert("출하처를 선택하세요");
			$('#order_destination1').focus();
			return;
		}
		if (!isEmpty($('#order_arrivaldate')))
		{
			alert("도착일을 입력하세요");
			$('#order_arrivaldate').focus();
			return;
		}
		if (!isEmpty($('#order_arrivaltime')))
		{
			alert("도착시간을 선택하세요");
			$('#order_arrivaltime').focus();
			return;
		}
		document.theForm.target="if_nvl";
		document.theForm.submit();
	}
	function totalinput()
	{
		if ($('#order_number').val()!="" && !isNumber($('#order_number')))
		{
			alert("수량은 숫자만 입력하세요");
			$('#order_number').val("");
			$('#order_number').focus();
			return;
		}
		if ($('#order_weight2').val()!="")
		{
			var inisum = $('#order_weight2').val()*$('#order_number').val();
			var html = $("#sum").html();
			html = " : "+ inisum +"KG";
			$("#sum").html(html);
			$("#order_total").val(inisum);
			return;
		}
	}
	function totalinput2()
	{
		if ($('#order_number').val()!="" && isNumber($('#order_number')) && $('#order_weight2').val()!="")
		{
			var inisum = $('#order_weight2').val()*$('#order_number').val();
			var html = $("#sum").html();
			html = " : "+ inisum +"KG";
			$("#sum").html(html);
			$("#order_total").val(inisum);
			return;
		}
	}
	function fnview(seq)
	{
		location="item_order_signup.html?menu1=<?=$menu1?>&menu2=<?=$menu2?>&seq="+seq;
	}
	function cancle_check()
	{
		location="item_order_signup.html?menu1=<?=$menu1?>&menu2=<?=$menu2?>";
	}
	function input_check()
	{
		document.theForm.mode.value="w";
		value_check();
	}
	function update_check()
	{
		document.theForm.mode.value="u";
		value_check();
	}
	function delete_check()
	{
		if(confirm("삭제하시겠습니까?"))
		{
			document.theForm.mode.value="d";
			document.theForm.target="if_nvl";
			document.theForm.submit();
		}
	}
	function fnlist()
	{
		location="item_order_signup.html?menu1=<?=$menu1?>&menu2=<?=$menu2?>";
	}
	$(document).ready(function(){
		if ($("#order_item1").val()!="")
		{
			fncGetItemJSON('item', 2, $("#order_item1").val(), $('#order_item2'));
			totalinput2();
		}
	});
</script>
</head>
<body>
<div id="wrap">
<!-- header start -->
<? include("../_layout/head.inc"); ?>
<!-- header end -->

<!-- view start -->
<? include("./item_order_edit.php"); ?>
<!-- view end -->

<!-- container start -->
	<div id="container">
    	<div class="subtit">
        	<p class="subtt01"><span>수발주입력 > 등록및조회</span></p>
		</div>
        <div class="contents">
        	<p class="tableTitle"><span class="b"></span>수발주 입력 <span class="notread"> [수발주번호예시 : yymmdd-숫자네자리연번]</span></p>
			<form name="theForm" method="post" action="./item_order_signup_proc.php">
			<input type="hidden" name="mode" id="mode" />
			<input type="hidden" name="menu1" id="menu1" value="<?=$menu1?>" />
			<input type="hidden" name="menu2" id="menu2" value="<?=$menu2?>" />
			<input type="hidden" name="seq" id="seq" value="<?=$seq?>" />
        	<table cellpadding="0" cellspacing="1" border="0" class="erpTable">
            	<tr>
                	<th>등록일</th>
                    <th>농협명</th>
					<th>거래방법</th>
                    <th>품목</th>
                    <th>품종</th>
                    <th>등급</th>
                    <th>규격</th>
                    <th>중량(kg)</th>
                    <th>수량</th>
                    <th>출하처</th>
                    <th>도착일</th>
                    <th>도착시간</th>
				</tr>
                <tr>
                	<td class="day_cal" >
                        <input type="text" id="order_date" value="<?=$ndate?>" name="order_date" title="등록일입력/달력을클릭해주세요." readonly class="boxinput w65" style="margin-right:2px;vertical-align:top;" />
                    </td>
                    <td>
                    	<select	name="jbnh_seq" id="jbnh_seq">
							<option value="">농협명</option>
							<?
								$codedata = & JBNH_GetSelect(0);
								JBNH_PrintOption($codedata, $jseq);
							?>
                        </select>
                    </td>
                     <td>
                    	<select name="order_type" id="order_type">
                        	<option value="">거래방법</option>
							<?
								$codedata = & Code_GetSelect("B", 2, 4,false);
								Code_PrintOption($codedata, 2, $otype);
							?>
                        </select>
                    </td>
					<td>
                    	<select name="order_item1" id="order_item1" onchange="fncGetItemJSON('item', 2, this.value, $('#order_item2'));">
                        	<option value="">품목명</option>
							<?
								$codedata = & Code_GetSelect("A", 1, 0,false);
								Code_PrintOption($codedata, 1, $oitem1);
							?>
                        </select>
						<input type="hidden" name="oitem2" id="oitem2" value="<?=$oitem2?>" />
                    </td>
                     <td>
                    	<select name="order_item2" id="order_item2">
                        	<option value="">품종</option>
                        </select>
                    </td>
                     <td>
						<input type="hidden" name="order_grade1" id="order_grade1" value="2" />
                    	<select name="order_grade2" id="order_grade2">
                        	<option value="">등급</option>
							<?
								$codedata = & Code_GetSelect("B", 2, 2,false);
								Code_PrintOption($codedata, 2, $ograde2);
							?>
                        </select>
                    </td>
                     <td>
						<input type="hidden" name="order_standard1" id="order_standard1" value="3" />
                    	<select name="order_standard2" id="order_standard2">
                        	<option value="">규격</option>
							<?
								$codedata = & Code_GetSelect("B", 2, 3,false);
								Code_PrintOption($codedata, 2, $ostandard2);
							?>
                        </select>
                    </td>
                     <td>
						<input type="hidden" name="order_weight1" id="order_weight1" value="1" />
                    	<select name="order_weight2" id="order_weight2" onchange="totalinput2();">
                        	<option value="">중량</option>
							<?
								$codedata = & Code_GetSelect("B", 2, 1,false);
								Code_PrintOption($codedata, 2, $oweight2, "KG");
							?>
                        </select>
                    </td>
                    <td><input type="text" id="order_number" name="order_number" title="수량입력" onblur="totalinput();" value="<?=$onumber?>" class="boxinput w30" /></td>
                    <td>
                    	<select name="order_destination1" id="order_destination1">
                        	<option value="">출하처</option>
							<?
								$codedata = & Code_GetSelect("c", 1, 0,false);
								Code_PrintOption($codedata, 1, $odestination1);
							?>
                        </select>
						<input type="hidden" name="order_destination2" id="order_destination2" value="2" />
                    </td>
                    <td class="day_cal">
                    	<input type="text" id="order_arrivaldate" name="order_arrivaldate" value="<?=$oarrivaldate?>" readonly title="도착일입력/달력을클릭해주세요."class="boxinput w65"  style="margin-right:2px;vertical-align:top;"/>
                    </td>
                    <td>
                    	<select name="order_arrivaltime" id="order_arrivaltime">
                        	<option value="" <?=($oarrivaltime=="")?"selected":""?>>선택</option>
                            <option value="24" <?=($oarrivaltime=="24")?"selected":""?>>24시</option>
                            <option value="23" <?=($oarrivaltime=="23")?"selected":""?>>23시</option>
                            <option value="22" <?=($oarrivaltime=="22")?"selected":""?>>22시</option>
                            <option value="21" <?=($oarrivaltime=="21")?"selected":""?>>21시</option>
                            <option value="20" <?=($oarrivaltime=="20")?"selected":""?>>20시</option>
                            <option value="19" <?=($oarrivaltime=="19")?"selected":""?>>19시</option>
                            <option value="18" <?=($oarrivaltime=="18")?"selected":""?>>18시</option>
                            <option value="17" <?=($oarrivaltime=="17")?"selected":""?>>17시</option>
                            <option value="16" <?=($oarrivaltime=="16")?"selected":""?>>16시</option>
                            <option value="15" <?=($oarrivaltime=="15")?"selected":""?>>15시</option>
                            <option value="14" <?=($oarrivaltime=="14")?"selected":""?>>14시</option>
                            <option value="13" <?=($oarrivaltime=="13")?"selected":""?>>13시</option>
                            <option value="12" <?=($oarrivaltime=="12")?"selected":""?>>12시</option>
                            <option value="11" <?=($oarrivaltime=="11")?"selected":""?>>11시</option>
                            <option value="10" <?=($oarrivaltime=="10")?"selected":""?>>10시</option>
							<option value="09" <?=($oarrivaltime=="09")?"selected":""?>>9시</option>
							<option value="08" <?=($oarrivaltime=="08")?"selected":""?>>8시</option>
							<option value="07" <?=($oarrivaltime=="07")?"selected":""?>>7시</option>
							<option value="06" <?=($oarrivaltime=="06")?"selected":""?>>6시</option>
                        </select>
                    </td>
                </tr>
				<tr>
					<td colspan="12" class="total">합계<span id="sum"></span></td>
				</tr>
            </table>
            <div class="BtnList">
            	<ul>
				<?if ($seq==""){?>
                  	<li><input type="button" class="btn_submit" title="등록" onclick="input_check();" /></li>
				<?}else{?>
					<li><input type="button" class="btn_modify" title="수정" onclick="update_check();"/></li>
                    <li><input type="button" class="btn_del" title="삭제" onclick="delete_check();"/></li>
					<li><input type="button" class="btn_cancel" title="취소" onclick="cancle_check();"/></li>
				<?}?>
                </ul>
            </div>
			<input type="hidden" name="order_total" id="order_total" value="<?=$ototal?>" />
            </form>
            <p class="tableTitle">
            	<span class="b"></span>수발주 목록</p>
				<div class="BtnList2">
				<input type="button" class="btn_excel" onClick="MNG.fncRtnfunc('excel');" title="엑셀로다운받기"/>
                <input type="button" class="btn_print" onClick="MNG.fncRtnfunc('print');" title="출력하기"/>
			</div>
			<input type="hidden" name="printtitle" id="printtitle" value="수발주목록" />
            <table cellpadding="0" cellspacing="1" border="0" class="erpTable" id="printtable">
            	<tr>
                	<th></th>
                	<th>등록일</th>
                    <th>농협명</th>
					<th>거래방법</th>
                    <th>품목</th>
                    <th>품종</th>
                    <th>등급</th>
                    <th>규격</th>
                    <th>중량</th>
                    <th>수량</th>
                    <th>합계</th>
                    <th>출하처</th>
					<th>도착일</th>
                    <th>도착시간</th>
				</tr>
<!-- list start -->
<? include("./item_order_list.php"); ?>
<!-- list end -->
            </table>
        </div>
    </div>
<!-- footer start -->
<? include("../_layout/footer.inc"); ?>
<!-- footer end -->
<iframe name=if_nvl id=if_nvl src='' style='display:none'></iframe>
</div>
</body>
</html>
